/**
 * Created by TAO on 2020/04/15 13:52.
 */
import Jsonp from 'jsonp'
import { stringify } from '@/utils'

export default function jsonp (url, data, option) {
  stringify(data) && (url += (url.indexOf('?') < 0 ? '?' : '&') + stringify(data))
  return new Promise((resolve, reject) => {
    Jsonp(url, option, (err, data) => {
      if (!err) {
        resolve(data)
      } else {
        reject(err)
      }
    })
  })
}
